import { App } from "leafer-ui";
import { IToolReturn } from "../types";
export const createBaseTool = (app: App, tool: IToolReturn) => {
  const handleEvents = (type: "off" | "on") => {
    Object.entries(tool.eventsMap).forEach((key) => {
      app[type](key[0], key[1]);
    });
  };
  return {
    registerEvents: () => {
      tool.active();
      handleEvents("on")
    },
    unregisterEvents: () => {
      tool.deactive();
      handleEvents("off");
    },
  };
};
